from libs.yuntongxun.sms import CCP
from celery_tasks.main import app



@app.task(bind=True,default_retry_delay=1,name='双倍的快乐')
def send_sms_code(self,mobile,sms_code):
    try:
        result = CCP().send_template_sms(mobile, [sms_code, 5], 1)
    except Exception as e:
        # retry（异常信息，最大重试次数）
        raise self.retry(exc=e,max_retries=3)
    if result != 0:
        raise self.retry(exc=Exception('发送异常'),max_retries=3)